package cn.ffcs.uec.staff.dao.impl;

import java.util.ArrayList;
import java.util.List;

import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;

import cn.ffcs.uec.staff.dao.UecPsnorgDao;
import cn.ffcs.uec.staff.model.UecPsnorg;
import cn.ffcs.uom.common.constants.BaseUnitConstants;
import cn.ffcs.uom.common.dao.BaseDaoImpl;
import cn.ffcs.uom.common.util.StrUtil;
import cn.ffcs.uom.common.vo.PageInfo;

@Repository("uecPsnorgDao")
@Transactional
public class UecPsnorgDaoImpl extends BaseDaoImpl implements UecPsnorgDao {

	@Override
	public PageInfo queryPageInfoByUecPsnorg(UecPsnorg uecPsnorg, int current,
			int pageSize) {
		if (null != uecPsnorg) {
			StringBuilder sb = new StringBuilder(
					" SELECT * FROM UEC_PSNORG T WHERE T.STATUS_CD = ? ");
			List<Object> params = new ArrayList<Object>();
			params.add(BaseUnitConstants.ENTT_STATE_ACTIVE);

			if (!StrUtil.isNullOrEmpty(uecPsnorg.getPkPsndoc())) {//判断数据是否是集团的
				sb.append(" AND T.PK_PSNDOC = ? ");
				params.add(uecPsnorg.getPkPsndoc());
			} else if (!StrUtil.isNullOrEmpty(uecPsnorg.getStaffId())) {
				sb.append(" AND T.STAFF_ID = ? ");
				params.add(uecPsnorg.getStaffId());
			}
			return this.jdbcFindPageInfo(sb.toString(), params, current,
					pageSize, UecPsnorg.class);
		}
		return null;
	}

}
